package com.shuai.frame.server;

import io.vertx.core.Vertx;

public class VertHttpServer implements HttpServer {
    @Override
    public void start(int port) {
        // 创建HTTP服务器
        Vertx vertx = Vertx.vertx();
        io.vertx.core.http.HttpServer httpServer = vertx.createHttpServer();

        // 配置请求处理器
        httpServer.requestHandler(new HttpServerHandler());

        // 在port端口启动HTTP服务器
        httpServer.listen(port, httpServerAsyncResult -> {
            if (httpServerAsyncResult.succeeded()) {
                System.out.printf("HttpServer正在端口{%s}监听...", port);
                System.out.println();
            } else {
                System.err.println("HttpServer启动失败");
            }
        });
    }
}
